package com.example.zhyq.login

import androidx.lifecycle.MutableLiveData
import com.example.base.entity.UserBean
import com.example.base.mvvm.BaseViewModel
import com.example.base.net.ApiService
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject

@HiltViewModel
class UserViewModel @Inject constructor(val apiService: ApiService): BaseViewModel() {

   val loginSuc = MutableLiveData<UserBean>()

    fun login(username:String,password:String) {
        httpRequest({apiService.login(username,password)},{loginSuc.value=it})
    }

    val registerSuc = MutableLiveData<UserBean>()

    fun register(username:String,password:String){
        httpRequest({apiService.register(username, password)},{registerSuc.value=it})
    }
}